﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.Linq.Expressions;
using Rhomble.Data;

namespace Rhomble.Services.Customers
{
	public class CustomerModel
	{
		[ScaffoldColumn(false)]
		public Guid ID { get; set; }

		[Required]
		[StringLength(200)]
		public string Name { get; set; }

		[ScaffoldColumn(false)]
		public DateTime CreatedDate { get; set; }

		[ScaffoldColumn(false)]
		public string CreatedBy { get; set; }

		[ScaffoldColumn(false)]
		public Guid CreatedByID { get; set; }
	}

	internal static class CustomerTransforms
	{
		internal static Expression<Func<Customer, CustomerModel>> EntityToModel = c => new CustomerModel
		{
			ID = c.CustomerPK,
			Name = c.Name,
			CreatedDate = c.CreatedDate,
			CreatedBy = c.CreatedByUser.LoweredUserName,
			CreatedByID = c.CreatedBy
		};

		internal static Func<CustomerModel, Customer> ModelToEntity = c => new Customer
		{
			Name = c.Name
		};
	}
}
